package cn.e2win.base.json.vo;

import java.io.Serializable;

import cn.e2win.base.controller.MyException;
import cn.e2win.biz.util.StringUtils;


public class Result implements Serializable{
	private String statusCode = SUCCESS; 
	private String message;
	private String navTabId;
	private String rel;
	private String callbackType;
	private String forwardUrl;
	private String confirmMsg;
	
	public static final String CLOSE_CURRENT = "closeCurrent";
	public static final String SUCCESS = "200";
	public static final String FAILED = "300";
	public static final String FORWARD = "forward";
	public Result(){
		this.callbackType = CLOSE_CURRENT;
	}
	
	public String getStatusCode() {
		return statusCode;
	}
	public void setStatusCode(String statusCode) {
		this.statusCode = statusCode;
	}
	
	public void setException(Exception e){
		if(e instanceof MyException){
			this.statusCode=FAILED;
			this.setMessage(((MyException) e).getMsg());
		}
	}
	
	public String getMessage() {
		if (StringUtils.isEmpty(message)) {
			if(SUCCESS.equals(this.statusCode)){
				this.message = "操作成功";
			} else if(FAILED.equals(this.statusCode)) {
				this.message = "操作失败,请联系管理员!";
			}
		}
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public String getNavTabId() {
		return navTabId;
	}
	public void setNavTabId(String navTabId) {
		this.navTabId = navTabId;
	}
	public String getRel() {
		return rel;
	}
	public void setRel(String rel) {
		this.rel = rel;
	}
	public String getCallbackType() {
		return callbackType;
	}
	public void setCallbackType(String callbackType) {
		this.callbackType = callbackType;
	}
	public String getForwardUrl() {
		return forwardUrl;
	}
	public void setForwardUrl(String forwardUrl) {
		this.forwardUrl = forwardUrl;
	}
	public String getConfirmMsg() {
		return confirmMsg;
	}
	public void setConfirmMsg(String confirmMsg) {
		this.confirmMsg = confirmMsg;
	}



//	private Integer entityId;
//
//	public Integer getEntityId() {
//		return entityId;
//	}
//
//	public void setEntityId(Integer entityId) {
//		this.entityId = entityId;
//	}
}
